Skip to content

build-gnu.sh: Use gsed for macOS & silent logging#10177

Closed
oech3 wants to merge 1 commit intouutils:mainfrom
oech3:patch-5
Closed

build-gnu.sh: Use gsed for macOS & silent logging#10177
oech3 wants to merge 1 commit intouutils:mainfrom
oech3:patch-5

Conversation

@oech3
Copy link
Copy Markdown
Contributor

@oech3 oech3 commented Jan 11, 2026

sed -i is impossible on macOS and no need to symlink coreutils with -v as we symlink false with -v.

@collinfunk
Copy link
Copy Markdown

MacOS does have sed -i, but it works a bit differently than GNU sed -i.

Here is how GNU's works:

$ echo a > input && sed -i 's/a/b/' input && cat input
b

Here is what happens on MacOS:

$ echo a > input && sed -i 's/a/b/' input && cat input
sed: 1: "input
": command i expects \ followed by text
$ cat input
a

Here is how to do the equivalent thing on MacOS:

$ echo a > input && sed -i '' 's/a/b/' input && cat input

What is happening here is that MacOS requires -i be given a backup suffix. The MacOS man page recommends against a zero-length extension like the above example, but doesn't stop you from doing it. They want you do do something like this:

$ echo a > input && sed -i '.bak' 's/a/b/' input && cat input && cat input.bak
b
a

This difference has caused me quite a bit of annoyance at work where most people use MacOS. :)

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Jan 12, 2026

command -v gsed && sed() { gsed \"\$@\"" -- "$@"; } might better to allow forgotting to use${SED}.

@oech3 oech3 closed this Jan 12, 2026
@oech3 oech3 deleted the patch-5 branch January 12, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants